export function getFormattedTime (now, timeType = "time") {
  // 创建一个新的Date对象，以避免修改原始日期对象
  // 如果没有提供日期对象，则使用当前日期
  // 确保now是一个有效的日期对象
  if (now && !(now instanceof Date)) {
    now = new Date(now);
  }
  if (!now) {
    now = new Date();
  }

  const year = now.getFullYear();
  const month = String(now.getMonth() + 1).padStart(2, "0"); // 月份从0开始，所以要加1
  const day = String(now.getDate()).padStart(2, "0");
  const hours = String(now.getHours()).padStart(2, "0");
  const minutes = String(now.getMinutes()).padStart(2, "0");
  const seconds = String(now.getSeconds()).padStart(2, "0");
  if (timeType == "time") {
    return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  } else {
    return `${year}-${month}-${day}`;
  }
}
